<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); ?>
<?php 
	$ci = & get_instance(); 	
	$id = $this->input->post('id', TRUE);
?>

<form action="<?php echo site_url('admin/dataman/coupon/add_coupon_submit');?>" name="add_coupon_submit" id="add_coupon_submit" method="post" enctype="multipart/form-data" >
<?php if(!$id): ?>		
	<div class="grid2"><span class="bold">*Code:</span></div>
	<div class="grid6"><input type="text" maxlength="45" id="code" name="code" value="" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="code_error">Required field.</span></div>
	
	<div class="clrboth"></div>	
	
	<div class="grid2"><span class="bold">*Coin:</span></div>
	<div class="grid6"><input type="text" maxlength="11" id="coin" name="coin" value="" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="coin_error">Required field.</span></div>
	
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">*Start time:</span></div>
	<div class="grid6"><input type="text" maxlength="255" id="start_time" name="start_time" value="" class="std-input"/><button id="start_time_btn">choose</button></div>
	<div class="grid2"><span class="bold red hidden" id="start_time_error">Required field.</span></div>
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">*End time:</span></div>
	<div class="grid6"><input type="text" maxlength="255" id="end_time" name="end_time" value="" class="std-input"/><button id="end_time_btn">choose</button></div>
	<div class="grid2"><span class="bold red hidden" id="end_time_error">Required field.</span></div>
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">*Mode:</span></div>
	<div class="grid6">
		<input type="radio" name="mode" value="single" checked="checked" />Single User 
		<input type="radio" name="mode" value="multiple" />Multiple Users 
	</div>
	<div class="grid2"><span class="bold red hidden" id="end_time_error">Required field.</span></div>
	<div class="clrboth"></div>
	
	<div class="grid2">&nbsp;</div>
	<div class="grid6"><input type="submit" class="button" /> <?php echo loader_image('id="loader_image" class="hidden"');?></div>
	<div class="clrboth"></div>	
<?php else: ?>
	<?php $COUPON = $ci->coupon_entity->init('id',$id);?>
	<div class="grid2"><span class="bold">*Code:</span></div>
	<div class="grid6"><input type="text" maxlength="45" id="code" name="code" value="<?php echo $COUPON->getCode();?>" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="code_error">Required field.</span></div>
	
	<div class="clrboth"></div>	
	
	<div class="grid2"><span class="bold">*Coin:</span></div>
	<div class="grid6"><input type="text" maxlength="11" id="coin" name="coin" value="<?php echo $COUPON->getCoin();?>" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="coin_error">Required field.</span></div>
	
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">*Start time:</span></div>
	<div class="grid6"><input type="text" maxlength="255" id="start_time" name="start_time" value="<?php echo sysDateTimeFormat($COUPON->getStartDate());?>" class="std-input"/><button id="start_time_btn">choose</button></div>
	<div class="grid2"><span class="bold red hidden" id="start_time_error">Required field.</span></div>
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">*End time:</span></div>
	<div class="grid6"><input type="text" maxlength="255" id="end_time" name="end_time" value="<?php echo sysDateTimeFormat($COUPON->getEndDate());?>" class="std-input"/><button id="end_time_btn">choose</button></div>
	<div class="grid2"><span class="bold red hidden" id="end_time_error">Required field.</span></div>
	<div class="clrboth"></div>
	
	<?php 
		$single = ($COUPON->getMode() == 'single') ? 'checked="checked"':'';
		$multiple = ($COUPON->getMode() == 'multiple') ? 'checked="checked"':'';
	?>
	<div class="grid2"><span class="bold">*Mode:</span></div>
	<div class="grid6">
		<input type="radio" name="mode" value="single" <?php echo $single;?> /> Single User 
		<input type="radio" name="mode" value="multiple" <?php echo $multiple;?> /> Multiple Users 
	</div>
	<div class="grid2"><span class="bold red hidden" id="end_time_error">Required field.</span></div>
	<div class="clrboth"></div>
	
	<input type="hidden" name="id" id="id" value="<?php echo $COUPON->getId();?>" />
	<div class="grid2">&nbsp;</div>
	<div class="grid6"><input type="submit" class="button" /> <?php echo loader_image('id="loader_image" class="hidden"');?></div>
	<div class="clrboth"></div>		
<?php endif; ?>	
</form>
